package com.itheima.web;

import com.itheima.dto.CheckgroupDto;
import com.itheima.pojo.Checkgroup;
import com.itheima.service.CheckgroupService;
import com.itheima.support.PageResult;
import com.itheima.support.QueryPageBean;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/checkgroup")
public class CheckgroupController {

    @DubboReference
    private CheckgroupService checkgroupService;

//    @PostMapping("/save")
//    public boolean save(@RequestBody Checkgroup checkgroup){
//        //第一步：先通过主键ID查询记录
//        //第二步：发送update语句进行更新操作
//        return checkgroupService.saveOrUpdate(checkgroup);
//    }

    @PostMapping("/save")
    public boolean save(@RequestBody CheckgroupDto checkgroupDto){
        return checkgroupService.saveGroup(checkgroupDto);
    }

    @PostMapping("/findByPage")
    public PageResult findByPage(@RequestBody QueryPageBean queryPageBean){
        return checkgroupService.findByPage(queryPageBean);
    }

    @GetMapping("/findAll")
    public List<Checkgroup> findAll(){
        return checkgroupService.list();
    }

}
